<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>素材管理</title>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <script src="../common/header.js"></script>
    <!-- 内容主体区域 -->
    <div id="LAY_app_body">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <!--检索项-->
                            <form class="layui-form" action="">
                                <div class="layui-inline">
                                    <a href="powder_friend_add.html" class="layui-btn layui-btn-sm">发起爆粉任务</a>
                                </div>
                            </form>
                            <!--表格内容区域-->
                            <table id="LAY-material-group-manage" lay-filter="LAY-material-group-manage"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="barDemo">
    <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="chatRecord()">聊天记录</button>
    <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="wechatMoments()">朋友圈</button>
</script>
<script type="text/html" id="headBar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm layui-btn-danger" onclick="batchDel()">删除</button>
    </div>
</script>
<script>
    var reloadList;
    var batchDel;
    var chatRecord;
    var wechatMoments;
    layui.use(['table'], function (table) {
        var $ = layui.$
        table = layui.table

        table.render({
            elem: '#LAY-material-group-manage'
            , url: '' //数据接口
            , page: true //开启分页
            , toolbar: '#headBar'
            , cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                , {field: 'wxid', title: '任务编号',width:150}
                , {field: 'img', title: '任务名称', width: 200}
                , {field: 'name', title: '爆粉类型', width: 120}
                , {field: 'remarks', title: '微信号分组', width: 100}
                , {field: 'origin', title: '打招呼语句', width: 100}
                , {field: 'origin1', title: '爆粉话术类型', width: 100}
                , {field: 'origin1', title: '任务总数量', width: 100}
                , {field: 'origin2', title: '已执行', width: 100}
                , {field: 'origin3', title: '加粉总成功数', width: 100}
                , {field: 'origin4', title: '进度', width: 100}
                // , {fixed: 'right', width: 270, align: 'center', toolbar: '#barDemo'}
            ]]
            , data: [
                {"wxid": "xiazi0311", "name": "霞子", "remarks": "无", "origin": "原始好友"},
                {"wxid": "xiazi0312", "name": "霞子", "remarks": "无", "origin": "爆粉"},
                {"wxid": "xiazi0313", "name": "霞子", "remarks": "无", "origin": "单独添加"},
                {"wxid": "xiazi0314", "name": "霞子", "remarks": "无", "origin": "对方主动添加"},
            ]
            , error: function (err) {
                if (err.code === 20002) {
                    layer.open({
                        type: 1,
                        title: false ,//不显示标题栏
                        closeBtn: false,
                        area: '300px;',
                        shade: 0.8,
                        id: 'LAY_layuipro', //设定一个id，防止重复弹出
                        btn: ['重新登录'],
                        btnAlign: 'c',
                        moveType: 1,
                        content: '<div style="padding: 60px 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">您的登录信息已失效，请重新登录！</div>',
                        success: function (layero) {
                            var btn = layero.find('.layui-layer-btn');
                            btn.find('.layui-layer-btn0').attr({
                                href: '../login/login.html'
                            });
                        }
                    });
                } else {
                    layer.msg(err.msg, {offset: '45vh', icon: 5, time: 2000});
                }
            }
        });

        batchDel = function (type) {
            var text = '确认删除好友吗？';
            layer.confirm(text, function (index) {
                layer.msg('删除了')
            });
        };

        chatRecord = function () {
            layer.open({
                type: 1
                ,id: 'layerDemo'
                ,content: '<div style="padding: 20px 100px;">这里是聊天记录</div>'
                ,btn: '关闭全部'
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
                ,yes: function(){
                    layer.closeAll();
                }
            });
        }
        wechatMoments = function () {
            layer.open({
                type: 1
                ,id: 'layerDemo'
                ,content: '<div style="padding: 20px 100px;">这里是朋友圈</div>'
                ,btn: '关闭全部'
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
                ,yes: function(){
                    layer.closeAll();
                }
            });
        }

        reloadList = function (reset, stayPage) {
            if (reset == true) {
                $('#group_id').find('option:first').attr("selected", false);
                $('#group_id').find('option:first').attr("selected", true);
                $('#login_status').find('option:first').attr("selected", false);
                $('#login_status').find('option:first').attr("selected", true);
                $('#search').val('');
                $('#changePwd').find('option:first').attr("selected", false);
                $('#changePwd').find('option:first').attr("selected", true);
                $('#LAY-date').val('');
            }
            var groupId = $('#group_id').find("option:selected").val();
            var loginStatus = $('#login_status').find("option:selected").val();
            var search = $('#search').val();
            var changePwd = $('#changePwd').find("option:selected").val();
            var date = $('#LAY-date').val();
            if (stayPage == true) {
                table.reload('LAY-material-group-manage', {
                    where: { //设定异步数据接口的额外参数，任意设
                        groupId: groupId,
                        loginStatus: loginStatus,
                        search: encodeURIComponent(search),
                        changePwd: changePwd,
                        date: date
                    }
                });
            } else {
                table.reload('LAY-material-group-manage', {
                    where: { //设定异步数据接口的额外参数，任意设
                        groupId: groupId,
                        loginStatus: loginStatus,
                        search: encodeURIComponent(search),
                        changePwd: changePwd,
                        date: date
                    }
                    , page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            }
        };
    });
</script>
</body>
</html>
